<?php

use Illuminate\Support\Facades\Route;

/*
|--------------------------------------------------------------------------
| API Routes
|--------------------------------------------------------------------------
|
| Here is where you can register API routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| is assigned the "api" middleware group. Enjoy building your API!
|
*/

Route::prefix('auth')
    -> controller(\App\Http\Controllers\AuthController::class)
    -> group(function () {
        Route::middleware('auth:sanctum') -> group(function () {
            Route::get('/logout', 'logout');
            Route::get('/info', 'info');
            Route::post('/set-password', 'setPassword');
            Route::post('/update-password', 'updatePassword');
            Route::post('/set-pay-password', 'setPayPassword');
            Route::post('/update-pay-password', 'updatePayPassword');
            Route::post('/check-phone', 'checkPhoneCode');
            Route::post('/update-phone', 'updatePhone');
            Route::post('/upload-avatar', 'updateAvatar');
            Route::post('/update-name', 'updateName');
            Route::post('/seller', 'sellerAuth');
            Route::post('/buyer', 'buyerAuth');
            Route::get('/im-token', 'imToken');
        });
        Route::post('/register', 'register');
        Route::post('/forget-password', 'forgetPassword');
        Route::post('/login', 'login');
        Route::post('/phone-login', 'phoneLogin');
        Route::get('/token', 'getUserToken');
});

Route::prefix('account')
    -> controller(\App\Http\Controllers\AccountController::class)
    -> group(function () {
        Route::middleware('auth:sanctum') -> group(function () {
            Route::post('/add-wallet', 'addWallet');
            Route::post('/delete-wallet', 'deleteWallet');
            Route::get('/query-account-balance', 'queryAccountBalance');
            Route::get('/query-wallet', 'queryAccount');
            Route::get('/query-wallet-address', 'queryWalletAddress');
        });
        Route::post('/add-swt', 'addSwt');
    });

Route::prefix('trade')
    -> middleware('auth:sanctum')
    -> controller(\App\Http\Controllers\TradeController::class)
    -> group(function () {
        Route::get('/query-account-balance', 'queryBalance');
        Route::get('/query-address-balance', 'queryAddressBalance');
        Route::get('/query-coin-balance', 'queryCoinBalance');
        Route::get('/query-buy-balance', 'queryBuyBalance');
        Route::get('/query-logs', 'queryLogs');
        Route::post('/transfer', 'handleTransfer');
    });

Route::prefix('transfer')
    ->middleware('auth:sanctum')
    ->controller(\App\Http\Controllers\TransferController::class)
    -> group(function () {
       Route::get('/transfer-view','transferView');
       Route::post('/create-transfer-order','createTransferOrder');
       Route::post('/cancel-transfer-order','cancelTransferOrder');
       Route::get('/transfer-order-list','getTransferOrderList');
       Route::get('/transfer-order-info','getTransferOrderInfo');
       Route::get('/transfer-order-buyer-info','getTransferOrderBuyerInfo');
       Route::get('/lock-order','lockOrder');
       Route::get('/pay-order','payOrder');
       Route::get('/confirm-pay-order','confirmPayOrder');
       Route::get('/cancel-pay-order','cancelPayOrder');
       Route::get('/seller-order-list', 'getSellerOrderList');
       Route::get('/buyer-order-list', 'getBuyerOrderList');
    });

Route::prefix('chains')
    -> middleware('auth:sanctum')
    -> controller(\App\Http\Controllers\ChainController::class)
    -> group(function () {
        Route::post('/add-user-chain', 'addUserChain');
        Route::get('/query-user-chain', 'queryUserChain');
        Route::get('/has-user-chain-info', 'hasUserChainInfo');
    });


Route::prefix('order')
    -> middleware('auth:sanctum')
    -> controller(\App\Http\Controllers\OrderController::class)
    -> group(function () {
        Route::post('/create-order', 'create');
        Route::get('/query-list', 'list');
        Route::get('/get-swt-buy-orders', 'getSwtBuyOrders');
});

Route::prefix('util')
    -> controller(\App\Http\Controllers\UtilController::class)
    -> group(function () {
        Route::get('/query-countries', 'queryCountries');
        Route::get('/send-sms-code', 'sendSmsCode');
        Route::get('/send-email-code', 'sendEmailCode');
        Route::get('/version', 'getAppVersion');
        Route::post('/upload', 'uploadFile');
        Route::get('/analysis', 'analysisIdCard');
});

Route::prefix('market') -> group(function () {
    Route::prefix('tickers')
        -> controller(\App\Http\Controllers\TickersController::class)
        -> group(function () {
            Route::get('/get-lists', 'getLists');
            Route::get('/get-tabs', 'getTabs');
            Route::get('/get-candles', 'getCandles');
            Route::get('/get-swt', 'getSwtChains');
            Route::get('/query-all-coins', 'getAllCoins');
            Route::get('/query-coin-chains', 'getCoinChains');
            Route::middleware('auth:sanctum') -> group(function () {
                Route::get('/get-recharge-info', 'getRechargeInfo');
                Route::get('/query-user-coins', 'getUserCoins');
                Route::post('/add-withdraw-order', 'addWithdrawOrder');
            });
        });
});

Route::prefix('pledge')
    -> controller(\App\Http\Controllers\PledgeController::class)
    -> group(function () {
        Route::get('/get-lists', 'getLists');
        Route::get('/get-lists-by-coin', 'getListsByCoin');
        Route::get('/get-pledge-info', 'getPledgeInfo');
        Route::middleware('auth:sanctum') -> group(function () {
            Route::post('/create-pledge-order', 'createPledgeOrder');
            Route::get('/get-order-list', 'getOrderList');
            Route::get('/get-order-info', 'getOrderInfo');
            Route::post('/cancel-pledge-order', 'cancelPledgeOrder');
            Route::get('/get-redeem-pledge-info', 'getRedeemPledgeInfo');
            Route::post('/redeem-pledge-order', 'redeemPledgeOrder');
        });
});
